import { roleList } from '../../../request/api'

interface StateRole {
    rolelist: Array<object>
}

const state = {
    rolelist: []
}

const getters = {
    getRole(state: StateRole) {
        return state.rolelist
    }
}

const mutations = {
    REQ_ROLELIST(state: StateRole, payload: any) {
        state.rolelist = payload
    }
}

const actions = {
    getRoleListActions(context: any) {
        roleList().then(res => {
            if (res.code == 200) {
                context.commit('REQ_ROLELIST', res.list)
            }
        })
    }
}

export default {
    state,
    getters,
    mutations,
    actions,
    namespaced: true
}